home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 2.5 KB | 94 lines | [TEXT/MPS ] |
- // The C++ Booch Components (Version 2.1)
- // (C) Copyright 1990-1993 Grady Booch. All Rights Reserved.
- //
- // BCSearcV.h
- //
- // This file contains the declaration of the vector searching tools.
-
- #ifndef BCSEARCV_H
- #define BCSEARCV_H 1
-
- #include "BCType.h"
-
- // Vector searching abstract base class
-
- template<class Item, class Sequence>
- class BC_TSearch {
- public:
-
- BC_TSearch();
- BC_TSearch(BC_Boolean (*IsEqual)(const Item& x, const Item& y));
- virtual ~BC_TSearch();
-
- virtual void
- SetIsEqualFunction(BC_Boolean (*IsEqual)(const Item& x, const Item& y));
- virtual BC_ExtendedIndex Location(const Sequence& target, const Item& key,
- BC_Index start = 0) = 0;
-
- protected:
-
- BC_Boolean (*fIsEqual)(const Item& x, const Item& y);
-
- };
-
- // Sequential searching class
-
- template<class Item, class Sequence>
- class BC_TSequentialSearch : public BC_TSearch<Item, Sequence> {
- public:
-
- BC_TSequentialSearch();
- BC_TSequentialSearch(BC_Boolean (*IsEqual)(const Item& x, const Item& y));
- virtual ~BC_TSequentialSearch();
-
- virtual BC_ExtendedIndex Location(const Sequence& target, const Item& key,
- BC_Index start = 0);
-
- };
-
- // Ordered searching class
-
- template<class Item, class Sequence>
- class BC_TOrderedSearch : public BC_TSearch<Item, Sequence> {
- public:
-
- BC_TOrderedSearch();
- BC_TOrderedSearch(BC_Boolean (*IsEqual)(const Item& x, const Item& y),
- BC_Boolean (*IsLessThan)(const Item& x, const Item& y));
- virtual ~BC_TOrderedSearch();
-
- virtual void
- SetIsLessThanFunction(BC_Boolean (*IsLessThan)(const Item& x, const Item& y));
- virtual BC_ExtendedIndex Location(const Sequence& target, const Item& key,
- BC_Index start = 0);
-
- protected:
-
- BC_Boolean (*fIsLessThan)(const Item& x, const Item& y);
-
- };
-
- // Binary searching class
-
- template<class Item, class Sequence>
- class BC_TBinarySearch : public BC_TSearch<Item, Sequence> {
- public:
-
- BC_TBinarySearch();
- BC_TBinarySearch(BC_Boolean (*IsEqual)(const Item& x, const Item& y),
- BC_Boolean (*IsLessThan)(const Item& x, const Item& y));
- virtual ~BC_TBinarySearch();
-
- virtual void
- SetIsLessThanFunction(BC_Boolean (*IsLessThan)(const Item& x, const Item& y));
- virtual BC_ExtendedIndex Location(const Sequence& target, const Item& key,
- BC_Index start = 0);
-
- protected:
-
- BC_Boolean (*fIsLessThan)(const Item& x, const Item& y);
-
- };
-
- #endif
-